import 'package:app/pages/main_page_drawer.dart';
import 'package:app/routes/app_routes.dart';
import 'package:business_getx/business_getx.dart';
import 'package:business_platform/business_platform.dart';
import 'package:business_render/business_render.dart';
import 'package:business_user/business_user.dart';
import 'package:flutter/material.dart';
import 'package:lib_core/lib_core.dart';
import 'package:lib_ui/lib_ui.dart';

class MainPage extends StatelessWidget {
  MainPage({super.key});

  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  late final userLogic = Get.put(UserLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      appBar: TransparentAppBar(
        title: 'Demo首页',
        leading: GestureDetector(
          child: const Icon(Icons.menu),
          onTap: () {
            _scaffoldKey.currentState?.openDrawer();
          },
        ),
      ),
      drawer: Drawer(
        width: Get.width * 0.65,
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
            topRight: Radius.circular(0),
            bottomRight: Radius.circular(0),
          ),
        ),
        child: MainPageDrawer(),
      ),
      body: SizedBox(
        width: double.maxFinite,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            CommonTipsWidget(
              content: const Text('这里只简单的通过put注入，不传tag参数，并且在其他地方分别通过find、put获取，看是否是同一个对象'),
              tips: const Text('GetX Controller注入'),
              onClick: () {
                BoostNavigator.instance.push(GetRoutes.controllerTest1);
              },
            ),
            CommonTipsWidget(
              content: const Text('Gets已自带该功能，核心代码在main.dart'),
              tips: const Text('国际化测试'),
              onClick: () {
                GetRoutes.translation.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('验证该生命周期触发时机'),
              tips: const Text('DidUpdateWidget'),
              onClick: () {
                RenderRoutes.didUpdateWidget.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('stateful组件的刷新机制，关键就是state的复用'),
              tips: const Text('StatefulWidget'),
              onClick: () {
                RenderRoutes.stateful.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('验证该生命周期触发时机'),
              tips: const Text('DidChangeDependencies'),
              onClick: () {
                RenderRoutes.didChangeDependencies.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('切换主题颜色'),
              tips: const Text('主题颜色变换'),
              onClick: () {
                // GetRoutes.theme.push();
                GetRoutes.lifecycle.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('嵌套原生TextView'),
              tips: const Text('嵌套原生TextView'),
              onClick: () {
                PlatformRoutes.text_view.push();
              },
            ),
            CommonTipsWidget(
              content: const Text('测试Flutter插件'),
              tips: const Text('测试Flutter插件'),
              onClick: () {
                AppRoutes.plugin.push();
              },
            ),
          ],
        ),
      ),
    );
  }
}
